.class public Lcom/teewoo/app/bus/ui/js/JSInterface;
.super Ljava/lang/Object;
.source "JSInterface.java"


# static fields
.field public static final DEFAULT_RANGE:I = 0x7d0

.field public static final LATITUDE:Ljava/lang/String; = "latitude"

.field public static final LONGITUDE:Ljava/lang/String; = "longitude"

.field public static final PAGE:I = 0x1

.field public static final STATION_ID:Ljava/lang/String; = "id"

.field public static final STATION_NAME:Ljava/lang/String; = "name"

.field public static nearByStation:Ljava/util/List;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/List",
            "<",
            "Lcom/teewoo/app/bus/model/Station;",
            ">;"
        }
    .end annotation
.end field


# instance fields
.field private context:Landroid/content/Context;

.field private handler:Landroid/os/Handler;

.field private isRefrshing:Z

.field private webView:Landroid/webkit/WebView;


# direct methods
.method static constructor <clinit>()V
    .locals 1

    .prologue
    .line 48
    const/4 v0, 0x0

    sput-object v0, Lcom/teewoo/app/bus/ui/js/JSInterface;->nearByStation:Ljava/util/List;

    .line 34
    return-void
.end method

.method public constructor <init>(Landroid/content/Context;Landroid/os/Handler;)V
    .locals 1
    .parameter "context"
    .parameter "handler"

    .prologue
    .line 52
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 50
    const/4 v0, 0x0

    iput-boolean v0, p0, Lcom/teewoo/app/bus/ui/js/JSInterface;->isRefrshing:Z

    .line 53
    iput-object p1, p0, Lcom/teewoo/app/bus/ui/js/JSInterface;->context:Landroid/content/Context;

    .line 54
    iput-object p2, p0, Lcom/teewoo/app/bus/ui/js/JSInterface;->handler:Landroid/os/Handler;

    .line 55
    check-cast p1, Landroid/app/Activity;

    .end local p1
    const v0, 0x7f0a001f

    invoke-virtual {p1, v0}, Landroid/app/Activity;->findViewById(I)Landroid/view/View;

    move-result-object v0

    check-cast v0, Landroid/webkit/WebView;

    iput-object v0, p0, Lcom/teewoo/app/bus/ui/js/JSInterface;->webView:Landroid/webkit/WebView;

    .line 56
    return-void
.end method

.method static synthetic access$0(Lcom/teewoo/app/bus/ui/js/JSInterface;)Landroid/webkit/WebView;
    .locals 1
    .parameter

    .prologue
    .line 46
    iget-object v0, p0, Lcom/teewoo/app/bus/ui/js/JSInterface;->webView:Landroid/webkit/WebView;

    return-object v0
.end method

.method static synthetic access$1(Lcom/teewoo/app/bus/ui/js/JSInterface;Z)V
    .locals 0
    .parameter
    .parameter

    .prologue
    .line 50
    iput-boolean p1, p0, Lcom/teewoo/app/bus/ui/js/JSInterface;->isRefrshing:Z

    return-void
.end method

.method static synthetic access$2(Lcom/teewoo/app/bus/ui/js/JSInterface;)Landroid/content/Context;
    .locals 1
    .parameter

    .prologue
    .line 42
    iget-object v0, p0, Lcom/teewoo/app/bus/ui/js/JSInterface;->context:Landroid/content/Context;

    return-object v0
.end method

.method static synthetic access$3(Lcom/teewoo/app/bus/ui/js/JSInterface;)Z
    .locals 1
    .parameter

    .prologue
    .line 50
    iget-boolean v0, p0, Lcom/teewoo/app/bus/ui/js/JSInterface;->isRefrshing:Z

    return v0
.end method

.method private getAdjustLocation(Lcom/teewoo/app/bus/model/Station;)Lcom/teewoo/app/bus/model/Station;
    .locals 2
    .parameter "station"

    .prologue
    .line 162
    sget-object v0, Lcom/teewoo/app/bus/ui/Home4StaticMap;->sqliteHepler:Lcom/teewoo/app/bus/db/MySqliteHelper;

    if-nez v0, :cond_0

    .line 163
    new-instance v0, Lcom/teewoo/app/bus/db/MySqliteHelper;

    iget-object v1, p0, Lcom/teewoo/app/bus/ui/js/JSInterface;->context:Landroid/content/Context;

    invoke-direct {v0, v1}, Lcom/teewoo/app/bus/db/MySqliteHelper;-><init>(Landroid/content/Context;)V

    sput-object v0, Lcom/teewoo/app/bus/ui/Home4StaticMap;->sqliteHepler:Lcom/teewoo/app/bus/db/MySqliteHelper;

    .line 164
    :cond_0
    if-nez p1, :cond_1

    .line 165
    const/4 v0, 0x0

    .line 166
    :goto_0
    return-object v0

    :cond_1
    sget-object v0, Lcom/teewoo/app/bus/ui/Home4StaticMap;->sqliteHepler:Lcom/teewoo/app/bus/db/MySqliteHelper;

    invoke-virtual {v0, p1}, Lcom/teewoo/app/bus/db/MySqliteHelper;->adjustGoogleMapOffset(Lcom/teewoo/app/bus/model/Station;)Lcom/teewoo/app/bus/model/Station;

    move-result-object v0

    goto :goto_0
.end method


# virtual methods
.method public callbackFromjs()V
    .locals 2

    .prologue
    .line 172
    iget-object v0, p0, Lcom/teewoo/app/bus/ui/js/JSInterface;->handler:Landroid/os/Handler;

    new-instance v1, Lcom/teewoo/app/bus/ui/js/JSInterface$2;

    invoke-direct {v1, p0}, Lcom/teewoo/app/bus/ui/js/JSInterface$2;-><init>(Lcom/teewoo/app/bus/ui/js/JSInterface;)V

    invoke-virtual {v0, v1}, Landroid/os/Handler;->post(Ljava/lang/Runnable;)Z

    .line 179
    return-void
.end method

.method public getGpsLocation()Ljava/lang/String;
    .locals 8

    .prologue
    const-wide/16 v6, 0x0

    .line 77
    new-instance v2, Lorg/json/JSONArray;

    invoke-direct {v2}, Lorg/json/JSONArray;-><init>()V

    .line 78
    .local v2, jsonArray:Lorg/json/JSONArray;
    new-instance v1, Lorg/json/JSONObject;

    invoke-direct {v1}, Lorg/json/JSONObject;-><init>()V

    .line 80
    .local v1, jsObject:Lorg/json/JSONObject;
    :try_start_0
    sget-wide v3, Lcom/teewoo/app/bus/ui/Home4StaticMap;->latitude:D

    cmpl-double v3, v3, v6

    if-eqz v3, :cond_0

    .line 81
    const-string v3, "latitude"

    sget-wide v4, Lcom/teewoo/app/bus/ui/Home4StaticMap;->latitude:D

    invoke-static {v4, v5}, Ljava/lang/String;->valueOf(D)Ljava/lang/String;

    move-result-object v4

    invoke-virtual {v1, v3, v4}, Lorg/json/JSONObject;->put(Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;

    .line 82
    :cond_0
    sget-wide v3, Lcom/teewoo/app/bus/ui/Home4StaticMap;->longitude:D

    cmpl-double v3, v3, v6

    if-eqz v3, :cond_1

    .line 83
    const-string v3, "longitude"

    sget-wide v4, Lcom/teewoo/app/bus/ui/Home4StaticMap;->longitude:D

    invoke-static {v4, v5}, Ljava/lang/String;->valueOf(D)Ljava/lang/String;

    move-result-object v4

    invoke-virtual {v1, v3, v4}, Lorg/json/JSONObject;->put(Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;
    :try_end_0
    .catch Lorg/json/JSONException; {:try_start_0 .. :try_end_0} :catch_0

    .line 91
    :cond_1
    invoke-virtual {v2, v1}, Lorg/json/JSONArray;->put(Ljava/lang/Object;)Lorg/json/JSONArray;

    .line 95
    invoke-virtual {v2}, Lorg/json/JSONArray;->toString()Ljava/lang/String;

    move-result-object v3

    :goto_0
    return-object v3

    .line 84
    :catch_0
    move-exception v3

    move-object v0, v3

    .line 85
    .local v0, e:Lorg/json/JSONException;
    invoke-virtual {v0}, Lorg/json/JSONException;->printStackTrace()V

    .line 89
    const/4 v3, 0x0

    goto :goto_0
.end method

.method public getNearByStation()Ljava/lang/String;
    .locals 13

    .prologue
    const/4 v12, 0x0

    .line 102
    iget-object v0, p0, Lcom/teewoo/app/bus/ui/js/JSInterface;->context:Landroid/content/Context;

    invoke-static {v0}, Lcom/teewoo/app/bus/util/Utils;->getNetworkStatus(Landroid/content/Context;)Z

    move-result v0

    if-nez v0, :cond_0

    .line 103
    iget-object v0, p0, Lcom/teewoo/app/bus/ui/js/JSInterface;->context:Landroid/content/Context;

    const v1, 0x7f080019

    invoke-static {v0, v1}, Lcom/teewoo/app/bus/util/ToastUtil;->showToastCenter(Landroid/content/Context;I)V

    move-object v0, v12

    .line 158
    :goto_0
    return-object v0

    .line 110
    :cond_0
    const/4 v10, 0x0

    .line 112
    .local v10, near:Lcom/teewoo/app/bus/model/NearByBo;
    :try_start_0
    sget-wide v0, Lcom/teewoo/app/bus/ui/Home4StaticMap;->latitude:D

    sget-wide v2, Lcom/teewoo/app/bus/ui/Home4StaticMap;->longitude:D

    const/16 v4, 0x7d0

    const/4 v5, 0x1

    invoke-static/range {v0 .. v5}, Lcom/teewoo/app/bus/util/SearchUtil;->getNearByStation(DDII)Lcom/teewoo/app/bus/model/NearByBo;
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    move-result-object v10

    .line 121
    invoke-virtual {v10}, Lcom/teewoo/app/bus/model/NearByBo;->getNearStation()Ljava/util/List;

    move-result-object v0

    sput-object v0, Lcom/teewoo/app/bus/ui/js/JSInterface;->nearByStation:Ljava/util/List;

    .line 122
    sget-object v0, Lcom/teewoo/app/bus/ui/js/JSInterface;->nearByStation:Ljava/util/List;

    if-eqz v0, :cond_1

    sget-object v0, Lcom/teewoo/app/bus/ui/js/JSInterface;->nearByStation:Ljava/util/List;

    invoke-interface {v0}, Ljava/util/List;->size()I

    move-result v0

    if-nez v0, :cond_2

    .line 123
    :cond_1
    iget-object v0, p0, Lcom/teewoo/app/bus/ui/js/JSInterface;->context:Landroid/content/Context;

    const v1, 0x7f08001a

    invoke-static {v0, v1}, Lcom/teewoo/app/bus/util/ToastUtil;->showToastCenter(Landroid/content/Context;I)V

    move-object v0, v12

    .line 128
    goto :goto_0

    .line 113
    :catch_0
    move-exception v0

    move-object v7, v0

    .line 114
    .local v7, e1:Ljava/lang/Exception;
    iget-object v0, p0, Lcom/teewoo/app/bus/ui/js/JSInterface;->context:Landroid/content/Context;

    const v1, 0x7f080018

    invoke-static {v0, v1}, Lcom/teewoo/app/bus/util/ToastUtil;->showToastCenter(Landroid/content/Context;I)V

    move-object v0, v12

    .line 119
    goto :goto_0

    .line 130
    .end local v7           #e1:Ljava/lang/Exception;
    :cond_2
    sget-object v0, Lcom/teewoo/app/bus/ui/js/JSInterface;->nearByStation:Ljava/util/List;

    invoke-interface {v0}, Ljava/util/List;->size()I

    move-result v0

    if-lez v0, :cond_5

    .line 132
    new-instance v9, Lorg/json/JSONArray;

    invoke-direct {v9}, Lorg/json/JSONArray;-><init>()V

    .line 133
    .local v9, jsonArray:Lorg/json/JSONArray;
    sget-object v0, Lcom/teewoo/app/bus/ui/js/JSInterface;->nearByStation:Ljava/util/List;

    invoke-interface {v0}, Ljava/util/List;->iterator()Ljava/util/Iterator;

    move-result-object v0

    :cond_3
    :goto_1
    invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z

    move-result v1

    if-nez v1, :cond_4

    .line 156
    invoke-virtual {v9}, Lorg/json/JSONArray;->toString()Ljava/lang/String;

    move-result-object v0

    goto :goto_0

    .line 133
    :cond_4
    invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v11

    check-cast v11, Lcom/teewoo/app/bus/model/Station;

    .line 134
    .local v11, sta:Lcom/teewoo/app/bus/model/Station;
    invoke-direct {p0, v11}, Lcom/teewoo/app/bus/ui/js/JSInterface;->getAdjustLocation(Lcom/teewoo/app/bus/model/Station;)Lcom/teewoo/app/bus/model/Station;

    move-result-object v11

    .line 135
    if-eqz v11, :cond_3

    .line 138
    new-instance v8, Lorg/json/JSONObject;

    invoke-direct {v8}, Lorg/json/JSONObject;-><init>()V

    .line 140
    .local v8, jsObject:Lorg/json/JSONObject;
    :try_start_1
    const-string v1, "id"

    invoke-virtual {v11}, Lcom/teewoo/app/bus/model/Station;->getId()Ljava/lang/Integer;

    move-result-object v2

    invoke-virtual {v8, v1, v2}, Lorg/json/JSONObject;->put(Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;

    .line 141
    const-string v1, "name"

    invoke-virtual {v11}, Lcom/teewoo/app/bus/model/Station;->getName()Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v8, v1, v2}, Lorg/json/JSONObject;->put(Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;

    .line 142
    const-string v1, "latitude"

    invoke-virtual {v11}, Lcom/teewoo/app/bus/model/Station;->getLat()D

    move-result-wide v2

    invoke-static {v2, v3}, Ljava/lang/String;->valueOf(D)Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v8, v1, v2}, Lorg/json/JSONObject;->put(Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;

    .line 143
    const-string v1, "longitude"

    invoke-virtual {v11}, Lcom/teewoo/app/bus/model/Station;->getLon()D

    move-result-wide v2

    invoke-static {v2, v3}, Ljava/lang/String;->valueOf(D)Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v8, v1, v2}, Lorg/json/JSONObject;->put(Ljava/lang/String;Ljava/lang/Object;)Lorg/json/JSONObject;

    .line 145
    invoke-virtual {v9, v8}, Lorg/json/JSONArray;->put(Ljava/lang/Object;)Lorg/json/JSONArray;
    :try_end_1
    .catch Lorg/json/JSONException; {:try_start_1 .. :try_end_1} :catch_1

    goto :goto_1

    .line 146
    :catch_1
    move-exception v0

    move-object v6, v0

    .local v6, e:Lorg/json/JSONException;
    move-object v0, v12

    .line 150
    goto/16 :goto_0

    .end local v6           #e:Lorg/json/JSONException;
    .end local v8           #jsObject:Lorg/json/JSONObject;
    .end local v9           #jsonArray:Lorg/json/JSONArray;
    .end local v11           #sta:Lcom/teewoo/app/bus/model/Station;
    :cond_5
    move-object v0, v12

    .line 158
    goto/16 :goto_0
.end method

.method public refreshAfterFiling(DD)V
    .locals 7
    .parameter "lat"
    .parameter "lon"

    .prologue
    .line 184
    iget-object v6, p0, Lcom/teewoo/app/bus/ui/js/JSInterface;->handler:Landroid/os/Handler;

    new-instance v0, Lcom/teewoo/app/bus/ui/js/JSInterface$3;

    move-object v1, p0

    move-wide v2, p1

    move-wide v4, p3

    invoke-direct/range {v0 .. v5}, Lcom/teewoo/app/bus/ui/js/JSInterface$3;-><init>(Lcom/teewoo/app/bus/ui/js/JSInterface;DD)V

    invoke-virtual {v6, v0}, Landroid/os/Handler;->post(Ljava/lang/Runnable;)Z

    .line 197
    return-void
.end method

.method public showOverlay()V
    .locals 2

    .prologue
    .line 62
    iget-object v0, p0, Lcom/teewoo/app/bus/ui/js/JSInterface;->handler:Landroid/os/Handler;

    new-instance v1, Lcom/teewoo/app/bus/ui/js/JSInterface$1;

    invoke-direct {v1, p0}, Lcom/teewoo/app/bus/ui/js/JSInterface$1;-><init>(Lcom/teewoo/app/bus/ui/js/JSInterface;)V

    invoke-virtual {v0, v1}, Landroid/os/Handler;->post(Ljava/lang/Runnable;)Z

    .line 70
    return-void
.end method

.method public showStationInfo(I)V
    .locals 2
    .parameter "id"

    .prologue
    .line 204
    iget-object v0, p0, Lcom/teewoo/app/bus/ui/js/JSInterface;->handler:Landroid/os/Handler;

    new-instance v1, Lcom/teewoo/app/bus/ui/js/JSInterface$4;

    invoke-direct {v1, p0, p1}, Lcom/teewoo/app/bus/ui/js/JSInterface$4;-><init>(Lcom/teewoo/app/bus/ui/js/JSInterface;I)V

    invoke-virtual {v0, v1}, Landroid/os/Handler;->post(Ljava/lang/Runnable;)Z

    .line 217
    return-void
.end method
